package com.efast.cafe.portal.controller.common;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.efast.cafe.framework.bean.ResultBean;
import com.efast.cafe.framework.controller.AbstractController;
import com.efast.cafe.portal.bean.base.PortalBaseLovBean;
import com.efast.cafe.portal.entity.base.PortalBaseLov;
import com.efast.cafe.portal.service.base.IPortalBaseLovService;

@Controller
public class CommonParameterController extends AbstractController{
	
	@Autowired
	private  IPortalBaseLovService portalBaseLovService;

	
	
	/**
	 * 查询单个LOV参数
	 * @param paramKey
	 * @param moduleName
	 * @return
	 */
	@RequestMapping(value = "/frame_center/common/parameterselect")
	public @ResponseBody List<PortalBaseLov>  getPortalBaseLovSelect(@RequestParam(required = true)String paramKey,@RequestParam(required = true)String moduleName){
		
		return portalBaseLovService.getPortalBaseLovSelect(paramKey, moduleName);
		
	}
	
	/**
	 * 查询多个lov参数
	 * @param paramKey
	 * @param moduleName
	 * @return
	 */
	@RequestMapping(value = "/frame_center/common/parameterselectlist")
	public @ResponseBody Map<String, List<PortalBaseLov>>  getPortalBaseLovSelectList(@ModelAttribute("portalBaseLovBean")PortalBaseLovBean portalBaseLovBean){
		
		return portalBaseLovService.getPortalBaseLovSelectList(portalBaseLovBean.getParamKeys(), portalBaseLovBean.getModuleName());
		
	}
	
	/**
	 * 查询多个module 对应多个lov参数
	 * @param paramKey
	 * @param moduleName
	 * @return
	 */
	@RequestMapping(value = "/frame_center/common/parameterselectlistbymodule")
	public @ResponseBody ResultBean  getPortalBaseLovSelectListByModule(@ModelAttribute("portalBaseLovBean")PortalBaseLovBean portalBaseLovBean){
		ResultBean result = new ResultBean(true, "");
		try{
			result.setObject(portalBaseLovService.getPortalBaseLovSelectListByModule(portalBaseLovBean));
			// modelAndView.setViewName("forward:/base/lov/page");
		}catch(Exception e){
			e.printStackTrace();
			result.setSuccess(false);
			result.setMessage(e.getMessage());
		}
		return result;
		
	}
}
